using SplineMesh;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Load : MonoBehaviour
{
    [SerializeField] private float Interval = 5;
    [SerializeField] private Spline SplineLoad;
    [SerializeField] private float Speed = 10;

    private float _leftTime = 0;

    private void Update()
    {
        if (LevelMgr.Instance.State == GameState.Running || LevelMgr.Instance.State == GameState.Over || LevelMgr.Instance.State == GameState.Stop)
        {
            if (_leftTime <= 0)
            {
                _leftTime = Interval;
                GameObject car = EnemyPool.Instance.Pool.Get();
                car.SetActive(true);
                car.GetComponent<EnemyCar>().Init(SplineLoad, Speed);
            }
            _leftTime -= Time.deltaTime;
        }
    }
}